<template>
  <view class="toTopView" @tap="toBackTop" v-if="isShow">
    <text class="XTXIconfont icon-fanhuidingbu1"></text>
  </view>
</template>

<script setup lang="ts">
import { ref, watch } from 'vue'

const props = defineProps<{ scrollDis: number }>()
const isShow = ref(false)
watch(
  () => props.scrollDis,
  (val) => {
    if (val > 500) {
      isShow.value = true
    } else {
      isShow.value = false
    }
  },
)
// 点击 滚回顶部
const toBackTop = () => {
  uni.pageScrollTo({
    scrollTop: 0,
    duration: 100,
    success: () => {
      console.log(456)
    },
  })
}
</script>

<style>
@import '@/static/iconfont/iconfont.css';
.toTopView {
  position: fixed;
  right: 50rpx;
  bottom: 50rpx;
  z-index: 999;
  width: 60rpx;
  height: 60rpx;
}
.icon-fanhuidingbu1 {
  font-size: 75rpx;
}
</style>
